//
//  CC_CircularImageView_CollectionView.m
//  HimalayaMountain
//
//  Created by dllo on 16/7/14.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CC_CircularImageView_CollectionView.h"

#import "CCBaseCollectionView.h"
#import "CC_CircularImage_Label_CollectionViewCell.h"
@interface CC_CircularImageView_CollectionView ()<UICollectionViewDataSource, UICollectionViewDelegate>

@property(nonatomic, retain)CCBaseCollectionView *collectionView;


@end


@implementation CC_CircularImageView_CollectionView

- (void)dealloc
{
    [_collectionView release];
    [_imageUrlsArray release];
    [_labelTextsArray release];
    [super dealloc];
}

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        
        self.imageUrlsArray = [NSArray array];
        self.labelTextsArray = [NSArray array];
        
        [self createCollectionView];
        
    }
    return self;
    
}


-(void)createCollectionView{
    
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
    
    flowLayout.itemSize = CGSizeMake((SCREENWIDTH - 15 - 30 * 4) / 4.5, SBHEIGHT - 30);
    
    flowLayout.sectionInset = UIEdgeInsetsMake(15, 15, -15, 0);
    flowLayout.minimumLineSpacing = 30;
    
    flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    
    self.collectionView = [[CCBaseCollectionView alloc]initWithFrame:self.bounds collectionViewLayout:flowLayout];
    [self addSubview:_collectionView];
   
    [_collectionView release];
    
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
   
    [self.collectionView registerClass:[CC_CircularImage_Label_CollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
    
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return self.imageUrlsArray.count;
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    CC_CircularImage_Label_CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    
    return cell;
    
    
    
}

@end
